#include <QFile>
#include "qlogger.hpp"

void QLoggerFileAppender::write (const QLoggerEvent &event)
{
    mutex.lock();

    QFile file(_filename);

    if (file.open(QFile::WriteOnly | QFile::Append)) {
        QTextStream out(&file);
        streamWrite(out, event);
        file.close();
    }

    mutex.unlock();
}

QLoggerFileAppender::QLoggerFileAppender (int level, const QString &filename, const QString &format) :
QLoggerAppender(format, level)
{
    _filename = filename;
}
